<!doctype html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="/A0723/include :: header('任务详情')"/>
</head>

<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">任务详情</h1>
</header>
<div class="mui-content">

    <ul class="task_jl">

    </ul>
</div>
<th:block th:include="/A0723/include :: footer"/>
<script th:src="@{/front/js/dist/clipboard.min.js}"></script>
<th:block th:include="/A0723/include :: common"/>
<script type="text/javascript">
    $(function () {
        taskInfo('[[${taskId}]]')
    })
    let code = ''
    var clipboard = new ClipboardJS('.btn', {
        text: function () {
            return code;
        }
    });

    clipboard.on('success', function (e) {
        console.info('Action:', e.action);
        console.info('Text:', e.text);
        console.info('Trigger:', e.trigger);
        mui.toast('已复制', {duration: 'long', type: 'div'})
    });


    //获取任务详情
    function taskInfo(taskId) {
        mui.ajax(ctx+'front/taskInfo/' + taskId, {
            dataType: 'json',//服务器返回json格式数据
            type: 'get',//HTTP请求类型
            timeout: 10000,//超时时间设置为10秒；
            headers: {'Content-Type': 'application/json'},
            success: function (res) {
                let data = res.data;
                if(data!=null){
                    code= data.videoUrl;
                    let str = '<li class="flex3" ">\n' +
                        '            <div class="task_jl_messg">\n' +
                        '                <div>发布平台：'+data.platformType.name+'</div>\n' +
                        '                <div>类型：'+formatterWay(data.type)+'</div>\n' +
                        '                <div>数量：'+data.num+'</div>\n' +
                        '                <div>视频地址：'+data.videoUrl+'<button type="button" data-clipboard-action="copy"  class="btn" >复制</button></div>\n' +
                        '                <div>发布时间：'+data.createTime+'</div>\n' +
                        '                <div><button type="button" onclick="receiveTask(' + data.id + ')" class="mui-btn mui-btn-blue">接取任务</button>' +
                        '<a style="margin-left: 15%;" onclick="openApp(\''+data.videoId+'\')"  class="mui-btn mui-btn-blue">打开视频</a></div>\n' +
                        '            </div>\n' +
                        '            <div class="task_jl_menoy">\n' +
                        '                <span>'+data.amount+'</span>元\n' +
                        '            </div>\n' +
                        '        </li>';

                    $(".task_jl").html('');
                    $(".task_jl").append(str);
                }else{
                    $(".task_jl").html('');
                    $(".task_jl").append('<li class="flex3" ">\n' +
                        '            <div class="task_jl_messg">\n' +
                            '抱歉，没找到该记录'+

                        '            </div>\n' +
                        '        </li>');
                }

            },
            error: function (xhr, type, errorThrown) {
                //异常处理；
                console.log(type);
            }
        });
    }
    /**
     * 任务类型
     * @param type
     * @returns {string}
     */
    function formatterWay(type) {
        return type === 1 ? "点赞" : type === 2 ? "关注" : type === 3 ? "互粉" : type === 4 ? "推荐奖" : type === 5 ? "团队奖" : type === 6 ? "购买套餐" : type === 7 ? "任务金" : '';
    }
    /**
     * 跳转抖音APP 并进入指定到填写的视频连接视频
     * @returns {string}
     */
    function openApp(id) {
        var scheme = "snssdk1128://detail?id="+id;
        plus.runtime.openURL(scheme)
    }
</script>
</body>

</html>
